package com.houfukude.Activity;

import com.houfukude.xtestmgr.R;

import android.content.Intent;
import android.graphics.Color;
import android.os.Bundle;
import android.support.v7.app.ActionBarActivity;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.LinearLayout;
import android.widget.ScrollView;
import android.widget.TextView;
import android.widget.Toast;

public class CalculateActivity extends ActionBarActivity {

	private LinearLayout layout;
	String[] text = new String[] { "视倾角计算", "最小二乘法计算", "岩层厚度计算","string1","string2","string2","string2","string2","string2","string2" };
	private OnClickListener tvClickListener = new OnClickListener() {

		@Override
		public void onClick(View view) {
			for (int i = 0; i < text.length; i++) {
				if(text[i].equals(view.getTag().toString())){
					Toast.makeText(getApplicationContext(), text[i],
							Toast.LENGTH_SHORT).show();
					Intent calculateInputActivity = new Intent("com.houfukude.Activity.CalculateInputActivity");
					calculateInputActivity.putExtra("calculteTitle", view.getTag().toString());
					startActivity(calculateInputActivity);
				}
			}

		}
	};

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_cal);
		ScrollView cal_sv = (ScrollView) findViewById(R.id.cal_scrollView);
		layout = (LinearLayout) cal_sv.findViewById(R.id.cal_linearLayout);
		layout.removeAllViews();
		setCalListView(layout);

	}

	private void setCalListView(LinearLayout layout) {
	
		for (int i = 0; i < text.length; i++) {
			TextView child = new TextView(getApplicationContext());
			child.setText(text[i]);
			child.setTextSize(25);
			child.setTextColor(Color.BLACK);
			child.setTag(text[i]);
			child.setOnClickListener(tvClickListener);
			layout.addView(child);
		}
	}
}
